﻿
using Mengsk.ProxyDelivery.Domain;
using Mengsk.ProxyDelivery.Print.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mengsk.ProxyDelivery.Print.Domain.PrintDataFormatters
{
    class PrintDataFormatterGoods_Info : PrintDataFormatter
    {

        public override PrintTemplateItemTypes AcceptType
        {
            get { return PrintTemplateItemTypes.GOODS_INFO; }
        }

        public override object Format(PrintTemplate template, PrintTemplateItem item, Order order)
        {
            StringBuilder sb = new StringBuilder();

            if (order.OrderGoodss != null && order.OrderGoodss.Count > 0)
            {
                foreach (var goods in order.OrderGoodss.Where(obj => (int)obj.State <= (int)OrderState.Shipped))
                {
                    sb.AppendLine(VendorServiceWithCatch.FormatVendorAreaAndDoor(goods.Vendor) + " " + VendorServiceWithCatch.GetVendorPingYingName(goods.Vendor).ToUpper() + " " + goods.Number + goods.Edtion + goods.Color + goods.Size + " (" + goods.Count + ")");
                }
            }

            if (order.OrderGifts != null && order.OrderGifts.Count > 0)
            {
                foreach (var gift in order.OrderGifts)
                {
                    sb.AppendLine(gift.GiftName + " " + gift.Count);
                }
            }

            return sb.ToString();
        }
    }
}
